﻿package com.crl.ui.controls.buttons
{
	import flash.display.MovieClip;
	
	/**
	 * 状态按钮基类,
	 * 4帧按钮类.
	 * 1 默认状态;
	 * 2 鼠标经过状态;
	 * 3 选择后与点击状态;
	 * 4 不可选状态;
	 * @author crl
	 */
	public class StateButton 
	{
		private var mc:MovieClip;
		public function StateButton(mc:MovieClip) 
		{
			
			this.mc = mc;
			gotoAndStop(1);
		}
		
		public function getView():MovieClip {
			return this.mc;
		}
		
		public function over(bool:Boolean):void {
			if(bool){
				gotoAndStop(2);
			}else {
				gotoAndStop(1);
			}
		}
		
		public function select(bool:Boolean):void {
			if(bool){
				gotoAndStop(3);
			}else {
				gotoAndStop(1);
			}
		}
		
		private var isSelect:Boolean;
		public function enabled(bool:Boolean):void {
			this.mc.buttonMode=bool;
			if (!bool) {
				isSelect=(this.mc.currentFrame == 3);
				gotoAndStop(4);
			}else {
				this.select(isSelect);
			}
		}
		
		protected function gotoAndStop(frame:int):void{
			this.mc.gotoAndStop(frame);
		}
		
	}
	
}